# 成功调用9222端口
import os
from time import sleep
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.edge.options import Options# 实现无可视化界面的操作,
import pyautogui

#定义浏览器对象
options = Options()#定义一个option对象
# options.add_argument("headless")#实现无可视化界面的操作,无可视化界面（无头浏览器）
#第一次打开的
# options.add_argument("--remote-debugging-port=9222")
# 之后测试的
options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver= webdriver.Edge(options = options)


# driver = webdriver.Edge()
# driver.maximize_window()
driver.set_window_size(800,750) # 设置浏览器大小 单位像素

url="https://baidu.com"
# url="https://www.sciencedirect.com/science/article/pii/S1674200123001293"
driver.get(url)

sleep(2)
driver.close()

# cmd管理员》netstat -ano |findstr 9222
# TCP  127.0.0.1:9222   0.0.0.0:0   LISTENING 3108
# TCP  127.0.0.1:9222   127.0.0.1:49676   FIN_WATI_2 4924
# TCP  127.0.0.1:9222   127.0.0.1:50193   ESTABLISHED 3108
# TCP  127.0.0.1:49676   127.0.0.1:9222   CLOSE_WAIT 2600
# TCP  127.0.0.1:50193   127.0.0.1:9222   ESTABLISHED 6048
# 》tasklist |findstr 3108
# msedge.exe  3108 Console  1  89376K
# msedgedriver.exe  6048 Console  1  10376K
